package com.hubei.JDBCTool;

import java.sql.Connection;
import java.sql.DriverManager;

public class JDBCTool {

    public static Connection getConnection() throws Exception {
            String username = "root";
            String password = "password";

            String url = "jdbc:mysql://127.0.0.1:3306/dongruandemo?characterEncoding=UTF-8&useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true";

            // 手动注册 JDBC 驱动
            Class.forName("com.mysql.cj.jdbc.Driver");

            Connection conn = DriverManager.getConnection(url, username, password);
        return conn;
    }
}
